<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>丢弃（删除）一个 MySQL 数据库</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.mysql-drop-db" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">mysql_drop_db</h1>
    <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_drop_db</span> &mdash; <span class="dc-title">丢弃（删除）一个 MySQL 数据库</span></p>

   </div>
 <div class="refsect1 description" id="refsect1-function.mysql-drop-db-description">
  <h3 class="title">说明</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>mysql_drop_db</strong></span>
       ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$database_name</code></span>
      [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$
        link_identifier
       </code></span>
     ] ) : <span class="type">bool</span></div>

    <p class="para rdfs-comment">
     <span class="function"><strong>mysql_drop_db()</strong></span> 尝试丢弃（删除）指定连接标识所关联的服务器上的一整个数据库。
    </p>
    <p class="para">
     成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
    </p>
    <p class="para">
     为向下兼容也可以用 <span class="function"><strong>mysql_dropdb()</strong></span>，但反对这样做。
    </p>
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <p class="para">
      不提倡使用 <span class="function"><strong>mysql_drop_db()</strong></span> 函数。最好用
      <span class="function"><a href="mysql_query.html" class="function">mysql_query()</a></span> 提交一条
      <em>SQL DROP DATABASE</em> 语句来替代。
     </p>
    </p></blockquote>
    <div class="warning"><strong class="warning">Warning</strong>
     <p class="para">
      如果 MySQL 扩展库是基于 MySQL 4.x 客户端库建立的，则本函数不可用。
     </p>
    </div>
    <p class="para">
     参见 <span class="function"><a href="mysql_create_db.html" class="function">mysql_create_db()</a></span> 和
     <span class="function"><a href="mysql_query.html" class="function">mysql_query()</a></span>。
    </p>
   </div>


 <div class="refsect1 parameters" id="refsect1-function.mysql-drop-db-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">database_name</code></dt>

     <dd>

      <p class="para">
       The name of the database that will be deleted.
      </p>
     </dd>

    
    <dt>
<code class="parameter">
link_identifier</code></dt>
<dd>
<p class="para">MySQL
连接。如不指定连接标识，则使用由 <span class="function"><a href="mysql_connect.html" class="function">mysql_connect()</a></span>
最近打开的连接。如果没有找到该连接，会尝试不带参数调用
<span class="function"><a href="mysql_connect.html" class="function">mysql_connect()</a></span>
来创建。如没有找到连接或无法建立连接，则会生成
<strong><code>E_WARNING</code></strong> 级别的错误。</p></dd>


   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.mysql-drop-db-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

  
 <div class="refsect1 examples" id="refsect1-function.mysql-drop-db-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2126">
    <p><strong>Example #1 <span class="function"><strong>mysql_drop_db()</strong></span> alternative example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'mysql_user'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'mysql_password'</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$link</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'Could&nbsp;not&nbsp;connect:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">mysql_error</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'DROP&nbsp;DATABASE&nbsp;my_db'</span><span style="color: #007700">;<br />if&nbsp;(</span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$sql</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Database&nbsp;my_db&nbsp;was&nbsp;successfully&nbsp;dropped\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Error&nbsp;dropping&nbsp;database:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">mysql_error</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.mysql-drop-db-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">本扩展自 PHP 5.5.0
起已废弃，并在自 PHP 7.0.0 开始被移除。应使用 <a href="book.mysqli.html" class="link">MySQLi</a>
或 <a href="ref.pdo_mysql.html" class="link">PDO_MySQL</a> 扩展来替换之。参见
<a href="mysqlinfo.api.choosing.html" class="link">MySQL：选择 API</a> 指南以及<a href="faq.databases.html#faq.databases.mysql.deprecated" class="link">相关 FAQ</a> 来获取更多信息。用以替代本函数的有：</p>
   <p class="para">
    <ul class="simplelist">
     <li class="member">Execute a <em>DROP DATABASE</em> query</li>
    </ul>
   </p>
  </p></blockquote>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    This function will not be available if the MySQL extension was built 
    against a MySQL 4.x client library.
   </p>
  </div>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    为了向下兼容，可以使用下列已废弃的别名：
    <span class="function"><strong>mysql_dropdb()</strong></span>
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysql-drop-db-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="mysql_query.html" class="function" rel="rdfs-seeAlso">mysql_query()</a> - 发送一条 MySQL 查询</span></li>
   </ul>
  </p>
 </div>

  </div></div></div></body></html>